package com.me.db;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class MeDBHelper extends SQLiteOpenHelper {

	public MeDBHelper(Context context) {
		super(context, MeDB.DB_NAME, null, MeDB.DB_VERSION);
	}

	@Override
	public void onCreate(SQLiteDatabase db) {

		db.execSQL(MeQuery.CREATE_EVENT_TABLE);
		db.execSQL(MeQuery.CREATE_TITLE_TABLE);
		db.execSQL(MeQuery.CREATE_LOCATION_TABLE);
		db.execSQL(MeQuery.CREATE_TITLE_PREFIX_INDEX);
		db.execSQL(MeQuery.CREATE_LOCATION_PREFIX_INDEX);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		db.execSQL(MeQuery.DELETE_EVENT_TABLE);
		db.execSQL(MeQuery.DELETE_TITLE_TABLE);
		db.execSQL(MeQuery.DELETE_LOCATION_TABLE);
		onCreate(db);
	}

	@Override
	public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		onUpgrade(db, oldVersion, newVersion);
	}

}
